package com.simon.app.controller;

import com.simon.app.entiy.User;
import com.simon.app.service.RefactorUserService;
import com.simon.app.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Index {

    @Autowired
    private UserService userService;

    @Autowired
    private RefactorUserService refactorUserService;

    @RequestMapping(value = "/home", method = RequestMethod.GET)
    public String home(){
        return userService.hello();
    }

    @RequestMapping(value = "/home2", method = RequestMethod.GET)
    public String home2(){
        return userService.hello("dddd", "fewer");
    }

    @RequestMapping(value = "/home3", method = RequestMethod.GET)
    public User home3(){
        User user = new User();
        user.setAge(12);
        user.setName("jjjlkalsjfjalskjdflafasdfasdf");
        return userService.hello(user);
    }

    @RequestMapping(value = "/home4", method = RequestMethod.GET)
    public String home4(){
        return userService.hello("home4");
    }

    @GetMapping("refact4")
    public String refactHome1() {
        return refactorUserService.hello("alskdjflakjsdfklajsdfkljaklsfj");
    }

    @GetMapping("refact5")
    public com.simon.october.dto.User refactHome2() {
        com.simon.october.dto.User user = new com.simon.october.dto.User();
        user.setName("klajsdf");
        user.setAge(123123123);
        return refactorUserService.hello(user);
    }
}
